//
//  HWAccountTradeProtocol.swift
//  HWanGame
//
//  Created by 王昌健 on 2022/6/17.
//  Copyright © 2022 94hwan. All rights reserved.
//

import UIKit

class HWAccountTradeProtocol: NSObject {
    var models:[HWGameDetailTradeModel]?
//    var oneModels:[HWGameDetailTradeModel]?
    var isOneYuan = false
    var didClickItem:((_:HWGameDetailTradeModel)->())?
    
    var scrollDidScroll:((_:UIScrollView)->())?
}

extension HWAccountTradeProtocol:UITableViewDelegate,UITableViewDataSource {
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//        if isOneYuan {
//            self.didClickItem?(oneModels![indexPath.row])
//        }else{
            self.didClickItem?(models![indexPath.row])
//        }
        
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
//        if isOneYuan {
//            return oneModels?.count ?? 0
//        }
        return models?.count ?? 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let tradeCell = HWGameDetailTradeOneYuanCell.cellWithTableView(tableView: tableView)

        tradeCell.isOneYuan = self.isOneYuan
            tradeCell.model = models?[indexPath.row]
        
        return tradeCell
    }
    
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        self.scrollDidScroll?(scrollView)
    }
    
}
